package net.j4love.spring.boot.webmvc.web;

import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author He Peng
 * @create 2017-05-19 18:14
 * @update 2017-05-19 18:14
 * @see
 */

@WebFilter(filterName = "MyFilter" , dispatcherTypes = DispatcherType.REQUEST,
        urlPatterns = "/*" , asyncSupported = true)
public class MyFilter implements Filter {

    private FilterConfig filterConfig;

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

        this.filterConfig = filterConfig;
        System.err.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%% \r\n MyFilter init");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        System.err.println("####################### \r\n MyFilter doFilter");
        chain.doFilter(request,response);
    }

    @Override
    public void destroy() {
        System.err.println("****************************** \r\n MyFilter destroy");
    }
}
